<% @filter = params[:filter].to_s.humanize.downcase %>
<% content_for :action_nav do %>
<div id="page-nav">
  <ul id="act-nav" class="clear">
  <% if admin? || @article.user_id == current_user.id -%>
    <li><%= link_to_remote _('Delete this article'), :url => {:action => 'destroy', :id => @article}, :confirm => _('Are you sure you want to delete this article?') %></li>
  <% unless @article.comment_age == -1 -%>
    <li id="close-article-comments"><%= link_to_remote _('Close comments for this article'), 
      :url => { :controller => 'admin/comments', :action => 'close', :id => @article } %></li>
  <% end -%>
  <% end -%>
  <% if controller.action_name == 'edit' -%>
    <li><%= link_to(_('Preview'), {:action => 'show', :id => @article}, {:target => '_blank'}) %></li>
  <% end -%>
    <li id="select">
      <a class="trigger" id="cog" href="#">&nbsp;</a>
      <div id="optgroup" style="display: none">
        <ul id="options">
        <% unless @article.new_record? -%>
          <li><%= link_to _('Edit this article'), :action => :edit, :id => @article, :version => nil %></li>
        <% end -%>
        <% if @article.comments.any? && controller.action_name != 'comments' -%>
          <li><%= link_to _("View comments"), :controller => 'articles', :action => 'comments', :id => @article %></li>
        <% end %>
        <% if controller.action_name == 'comments' && @comments.any? -%>
          <li><%= link_to_remote _("Delete all %{:filter} comments") % {:filter => @filter != 'all' ? @filter : ''}, :confirm => _("Are you sure you wish to delete all %{filter} comments?") % {:filter => @filter != 'all' ? @filter : ''},
              :url => { :action => 'destroy_comment', :id => @article }, :with => "ArticleForm.getAvailableComments().toQueryString('comment')"
            %></li>
        <% end -%>
        </ul>
      </div>
    </li>
  </ul>
</div>

<div id="filter" class="manual">
  <ul class="clear">
    <li><a href="#">&nbsp;</a></li>
  </ul>
  <ul id="attributes">
    <% unless controller.action_name == 'comments' %>
    <li><label for="search"><%= _('Revision:') %></label></li>
    <li>
      <select name="filter" id="revisionnum">
        <option value="0"><%= _('Newest') %></option>
        <%= options_from_collection_for_select @article.versions.reverse, :version, :version, params[:version].to_i %>
      </select>
    </li>
    <% end %>
    <% if controller.action_name == 'comments' -%>
    <li><label for="comments_view"><%= _('Show comments:') %></label></li>
    <li>
      <select id="comments-view">
        <%= options_for_select [_('All'), _('Unapproved'), _('Approved')], params[:filter].to_s.humanize %>
      </select>
    </li>
    <% end %>
  </ul>
</div>
<% end unless @article.new_record? && @article.comments.empty? -%>